/**
 * Progetto PRAISED.
 * 25/gen/2011
 */
package it.uniroma3.dia.praised.core.datasource;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author Accosta Augusto
 * @author Lopez Elisabetta
 * 
 */
public class DataSource {

	private static DataSource instance = null;

	private DataSource() {
	}

	public static DataSource getInstance() {
		if (instance == null) {
			instance = new DataSource();
		}
		return instance;
	}

	public Connection getConnection() {
		Connection connection = null;
		try {
			// Load the JDBC driver
			String driverName = "oracle.jdbc.driver.OracleDriver";
			Class.forName(driverName);

			// Create a connection to the database
			String serverName = "127.0.0.1";
			String portNumber = "1521";
			String sid = "orcl";
			String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
			String username = "Bioinformatics";
			String password = "bioinformatics";

			connection = DriverManager.getConnection(url, username, password);

		} catch (ClassNotFoundException e) {
			// Could not find the database driver
		} catch (SQLException e) {
			// Could not connect to the database
		}
		return connection;
	}
}
